#!/bin/bash

status=`cat /var/run/wview/html.sts | awk '/status =/ {print $NF}'`

if [ $status -eq "1" ]; then exit 0; fi
if [ $status -eq "3" ]; then exit 0; fi

array=("Not Started" "Booting" "Wait for wviewd" "Running" "Shutdown" "Error")

echo "On "`date`", html process was in state ${array[$status - 1]}, restarted wview" >> /home/pi/logs/html_log

sudo service wview restart

exit 0
